<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>个人中心</title>
    <#include "../common/link.ftl">
    <link type="text/css" rel="stylesheet" href="/js/plugins/uploadifive/uploadifive.css" />
    <script type="text/javascript" src="/js/plugins/uploadifive/jquery.uploadifive.min.js"></script>
    <script>
        $(function () {
            // 图片上传
            $('.imgBtn').uploadifive({
                'auto' : true,    // 自动发送图片上传请求
                'uploadScript' : '/uploadImg.do',  // 图片上传的请求路径
                buttonClass:"btn-link",    // 点击按钮的class
                'fileObjName' : 'pic',   // 文件上传的参数名
                'buttonText' : '浏览...',
                'fileType' : 'image',  // 上传文件类型
                'multi' : false,    // 是否上传多个
                'fileSizeLimit'   : 5242880,  // 每次上传限制的文件大小
                'removeCompleted' : true, //取消上传完成提示
                'uploadLimit' : 1,  // 上传个数限制
                //'queueSizeLimit'  : 10,   // 文件上传区域大小的限制
                'overrideEvents': ['onDialogClose', 'onError'],    //onDialogClose 取消自带的错误提示
                'onUploadComplete' : function(file, data) {  // 回调函数
                    $("#imgUrl").val(data);
                    $("#coverUrl").attr("src" ,data);  // data 约定是json格式的格式地址
                },
                onFallback : function() {
                    $.messager.alert("温馨提示","该浏览器无法使用!");
                }
            });

            // 保存
            $("#submitBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    if(data.code == 200){ //用alert或者popup都可以
                        $.messager.alert("温馨提示","保存成功!2s后跳转活动管理页面。")
                        window.setTimeout(function () {
                            window.location.href = "/activity/admin/list.do";
                        },2000)
                    }else{
                        $.messager.popup(data.msg)
                    }
                });
            })

            // 取消
            $(".cancleBtn").click(function () {
                //document.referrer 上一个请求路径
                var url = document.referrer ? document.referrer : "/";
                window.location.href = url;
            });
        })
    </script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="admin"/>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>个人中心</h1>
        </section>
        <section class="content">
            <div class="box">
                <form class="form-horizontal" action="/admin/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" value="${(admin.id)!}" name="id" >
                    <div class="form-group" style="margin-top: 10px">
                        <label for="number" class="col-sm-2 control-label">编号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="number" name="number" value="${(admin.number)!}" placeholder="请输入超管编号">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="nickName" class="col-sm-2 control-label">昵称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="nickname" name="nickname" value="${(admin.nickname)!}" placeholder="请输入昵称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="userName" class="col-sm-2 control-label">用户名：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="username" name="username" value="${(admin.username)!}" placeholder="请输入用户名" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="userName" class="col-sm-2 control-label">密码：</label>
                        <div class="col-sm-6">
                            <input type="password" class="form-control" id="password" name="password" value="${(admin.password)!}" placeholder="请输入密码">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="teacher" class="col-sm-2 control-label">负责老师：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="teacher" name="teacher" value="${(admin.teacher)!}" placeholder="请输入负责老师名字">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="teacherMobile" class="col-sm-2 control-label">负责老师电话：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="teacherMobile" name="teacherMobile" value="${(admin.teacherMobile)!}" placeholder="请输入负责老师电话">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sex" class="col-sm-2 control-label">性别：</label>
                        <div class="col-sm-6">
                            <input type="radio" id="boy" name="sex" value="男" <#if (admin.sex!)=='男'>checked</#if> />男
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" id="girl" name="sex" value="女" <#if (admin.sex!)=='女'>checked</#if>/>女
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="age" class="col-sm-2 control-label">年龄：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="age" name="age" value="${(admin.age)!}" placeholder="请输入年龄">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="mobile" class="col-sm-2 control-label">联系方式：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="mobile" name="mobile" value="${(admin.mobile)!}" placeholder="请输入年龄">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="email" class="col-sm-2 control-label">电子邮箱：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="email" name="email" value="${(admin.email)!}" placeholder="请输入邮箱">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="imgUrl" class="col-sm-2 control-label">图片：</label>
                        <div class="col-sm-8">
                            <input type="hidden"  class="form-control" name="imgUrl" value="${(admin.imgUrl)!}" id="imgUrl">
                            <img src="${(admin.imgUrl)!'/images/default.jpg'}" width="100px" id="coverUrl">
                            <button type="button" class="imgBtn">浏览</button>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="remarks" class="col-sm-2 control-label">备注：</label>
                        <div class="col-sm-6">
                            <textarea  class="form-control" id="remarks" name="remarks" >${(admin.remarks)!}</textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-1 col-sm-6" style="margin-left: 35%">
                            <!--button如果是在form表单内部,不写type默认就是submit-->
                            <!-- 验证插件只支持submit按钮提交-->
                            <button id="submitBtn" type="button" class="btn btn-primary" style="margin-right: 20px; margin-bottom: 10px">保存</button>
                            <button type="button" class="btn btn-default cancleBtn" data-dismiss="modal" style="margin-left: 20px; margin-bottom: 10px">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>

</body>
</html>
